home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
US Department of Defenseā¦ndamentals 1.0 2004 April
/
US Department of Defense: Firewall & Router Fundamentals 1.0 2004 April.iso
/
text_only
/
includes
/
sco_functions.js
< prev
next >
Wrap
Text File
|
2004-03-11
|
13KB
|
528 lines
function initialize_page()
{
//figure next and previous page URLs
//DO NEXT PAGE
var tmp_page_type = "";
var tmp_page_id = "";
if (API_WIN.RUN_REVIEW) {
tmp_page_id = parse_string(API_WIN.REVIEW_PAGES,",",API_WIN.REVIEW_PAGE_NUM + 1);
}
else {
if (PAGE_NUM < MAX_PAGE_NUM) {
//get next page id
tmp_page_id = API_WIN.DT_PAGE_LIST[PAGE_NUM];
}
}
if (tmp_page_id != "") {
tmp_page_type = API_WIN.get_page_type(tmp_page_id);
NEXT_PAGE = PATH_EXT + API_WIN.get_content_url(tmp_page_id,tmp_page_type);
}
else {
NEXT_PAGE = "close";
if (AUTO_COMPLETION)
SCO_STATUS = "c";
}
//DO PREVIOUS PAGE
tmp_page_type = "";
//convert prev page num into padded str
tmp_page_id = "";
if (API_WIN.RUN_REVIEW) {
tmp_page_id = parse_string(API_WIN.REVIEW_PAGES,",",API_WIN.REVIEW_PAGE_NUM - 1);
}
else {
if (PAGE_NUM > 1) {
//get next page id
tmp_page_id = API_WIN.DT_PAGE_LIST[PAGE_NUM - 2];
}
}
if (tmp_page_id != "") {
tmp_page_type = API_WIN.get_page_type(tmp_page_id);
PREV_PAGE = PATH_EXT + API_WIN.get_content_url(tmp_page_id,tmp_page_type);
}
else {
PREV_PAGE = "close";
DISABLE_PREV = true;
}
}
function start_page()
{
//show interface images
show_interface();
if (API_WIN.RUNNING_QUEST) {
DISABLE_PREV = true;
if (API_WIN.QUEST_NUM <= API_WIN.MAX_QUEST_NUM)
DISABLE_NEXT = true;
}
if (!RUN_508) {
if (DISABLE_NEXT)
document.NEXT.src = NEXT_DE.src;
else
document.NEXT.src = NEXT_DEF.src;
if (DISABLE_PREV)
document.PREVIOUS.src = PREVIOUS_DE.src;
else
document.PREVIOUS.src = PREVIOUS_DEF.src;
}
LOAD_DONE = true;
if ((ENABLE_AUDIO) && ((PAGE_TYPE == "flash") || (AUDIO_TYPE == "flash"))) {
if ("undefined" != typeof get_obj_style("flash_obj").display) {
var obj_style = get_obj_style("flash_obj");
obj_style.display = "";
if ("undefined" != typeof document.flashplayer.focus) {
document.flashplayer.focus();
}
}
}
//show audio narrative
show_audio();
//show LCMS Review Window, enabled
if ((API_WIN.LCMS_REVIEW) && (!API_WIN.RUN_REVIEW)) {
var tmp_url = API_WIN.LCMS_REVIEW_PATH + API_WIN.LCMS_REVIEW_PAGE + "&pageNumber=" + parseInt(PAGE_NUM) + "&displayTypeIndex=" + API_WIN.CUR_DT;
open_lcms_review(tmp_url);
}
//send status & bookmark, if not running question or review
if ((!API_WIN.RUN_REVIEW) && (!API_WIN.RUNNING_QUEST)) {
API_WIN.set_sco_status("1",SCO_STATUS);
API_WIN.set_sco_location("1",PAGE_NUM);
}
if ("function" == typeof content_start_page) {
content_start_page();
}
}
function replay_page()
{
location.reload();
}
function exit_page()
{
API_WIN.close_child_windows("exit_page",window.name);
}
function goto_page(page,direction)
{
if ((DISABLE_NEXT == true && direction == "next") || (DISABLE_PREV == true && direction == "previous")) {
//nothing
//alert("You can not continue at this point. Please try a different option.");
}
else {
if (page == "close") {
if (API_WIN.WIN_TYPE == "new_window")
window.close();
if (API_WIN.WIN_TYPE == "current_window")
goto_menu();
if (API_WIN.WIN_TYPE == "frame") {
API_WIN.sco_finish();
//window.location.href="about:blank";
}
}
else {
if (page != "")
window.location.href = page;
}
}
}
function goto_next_page()
{
if (!DISABLE_NEXT) {
//going to course page or question page?
if ((API_WIN.RUN_QUEST) || (API_WIN.RUNNING_QUEST)) {
//are we already in a question?
if (API_WIN.RUNNING_QUEST) {
goto_next_question();
}
else {
//go to questions
goto_page("questions/start.htm","");
}
}
else {
//increment opener PAGE_NUM or REVIEW_PAGE_NUM
if ((API_WIN.RUN_REVIEW) && (window.name == "REVIEW_WIN"))
API_WIN.REVIEW_PAGE_NUM += 1;
else
API_WIN.PAGE_NUM += 1;
goto_page(NEXT_PAGE,'next');
}
}
}
function goto_prev_page()
{
//are we running a question? if so previous not allowed
if ((!API_WIN.RUNNING_QUEST) && (!DISABLE_PREV)) {
//decrement opener PAGE_NUM or REVIEW_PAGE_NUM
if (API_WIN.RUN_REVIEW)
API_WIN.REVIEW_PAGE_NUM -= 1;
else
API_WIN.PAGE_NUM -= 1;
goto_page(PREV_PAGE,'previous');
}
}
function goto_menu()
{
if ((API_WIN.FILE_LMS) || (API_WIN.RUN_TYPE == "flms"))
API_WIN.flms_sco_finish('../menu.htm');
else
window.close();
}
function goto_spec_page(page_num,force_nav_rules)
{
if (!isNaN(page_num)) {
if (API_WIN.RUN_REVIEW) {
alert("This functionality is not supported in the Review Mode.");
}
else {
page_num = parseFloat(page_num);
if ((page_num >= 1) && (page_num <= MAX_PAGE_NUM)) {
var page_str = convert_num_to_str(page_num);
var page_type = API_WIN.get_page_type(page_str,API_WIN.PAGE_TYPE,LIST_FLASH_PAGES,LIST_HTML_PAGES);
var page_url = PATH_EXT + API_WIN.get_content_url(page_str,page_type);
if (force_nav_rules) {
if ((page_num > PAGE_NUM) && (!DISABLE_NEXT)) {
API_WIN.PAGE_NUM = page_num;
goto_page(page_url,"");
}
if ((page_num < PAGE_NUM) && (!DISABLE_PREV)) {
API_WIN.PAGE_NUM = page_num;
goto_page(page_url,"");
}
}
else {
API_WIN.PAGE_NUM = page_num;
goto_page(page_url,"");
}
}
}
}
}
function enable_next(bln_temp)
{
DISABLE_NEXT = !bln_temp;
if (document.NEXT) {
if (DISABLE_NEXT) {
document.NEXT.src = NEXT_DE.src;
}
else {
document.NEXT.src = NEXT_DEF.src;
}
if (ORIG_IMG) {
if (ORIG_IMG.name == "NEXT") {
ORIG_IMG.src = document.NEXT.src;
}
}
}
}
function enable_previous(bln_temp)
{
DISABLE_PREV = !bln_temp;
if (document.PREVIOUS) {
if (DISABLE_PREV) {
document.PREVIOUS.src = PREVIOUS_DE.src;
}
else {
document.PREVIOUS.src = PREVIOUS_DEF.src;
}
if (ORIG_IMG) {
if (ORIG_IMG.name == "PREVIOUS") {
ORIG_IMG.src = document.PREVIOUS.src;
}
}
}
}
function set_status(sub_sco,status)
{
API_WIN.set_sco_status(sub_sco,status);
}
function set_location(sub_sco,location)
{
API_WIN.set_sco_location(sub_sco,location);
}
function flash_next()
{
if (!DISABLE_NEXT)
FN_TIMER = setInterval("hacked_fn();",1000);
}
function hacked_fn()
{
if (FN_TIMER != "")
clearInterval(FN_TIMER);
document.NEXT.src = NEXT_FLASH.src;
}
function open_review(review_pages)
{
if (API_WIN.RUN_REVIEW) {
if (API_WIN.RV_WIN != null) {
API_WIN.RV_WIN.close();
API_WIN.RV_WIN = null;
}
API_WIN.RUN_REVIEW = false
}
//set REVIEW_PAGES
API_WIN.RUN_REVIEW = true;
API_WIN.REVIEW_PAGES = review_pages;
API_WIN.REVIEW_PAGE_NUM = 1;
API_WIN.REVIEW_PAGE = parse_string(API_WIN.REVIEW_PAGES,",",API_WIN.REVIEW_PAGE_NUM);
if (API_WIN.REVIEW_PAGE != "") {
var tmp_page_type = API_WIN.get_page_type(API_WIN.REVIEW_PAGE);
var tmp_page_url = API_WIN.get_content_url(API_WIN.REVIEW_PAGE,tmp_page_type);
API_WIN.RV_WIN=open(tmp_page_url,"REVIEW_WIN","location=no,scrollbars=no,resizeable=no,width=" + MEDIA_WIDTH + ",height=" + (parseInt(MEDIA_HEIGHT) + parseInt(API_WIN.RV_WIN_OFFSET)) + ",toolbar=no,directories=no,menubar=no,status=yes,");
API_WIN.RV_WIN.focus();
}
}
function open_popup(page_url,left,top,width,height,scroll,resize,menu)
{
API_WIN.open_popup(page_url,left,top,width,height,scroll,resize,menu);
}
function open_glossary(term)
{
//API_WIN.open_glossary(term);
alert("The Glossary is not available yet.");
}
function open_prefs()
{
API_WIN.open_prefs();
}
function open_refs()
{
//API_WIN.open_refs();
alert("Resources are not available yet.");
}
function open_help()
{
//API_WIN.open_help();
alert("Help is not available yet.");
}
function open_map()
{
//API_WIN.open_map();
alert("The Course Map is not available yet.");
}
function open_lcms_review(page_url)
{
API_WIN.open_lcms_review(page_url);
}
function show_audio()
{
if (SHOW_AUDIO) {
if (PAGE_NUM > 0)
API_WIN.open_audio_win(API_WIN.get_audio_url(CUR_PAGE_ID));
}
else if (API_WIN.AUDIO_WIN != null) {
API_WIN.AUDIO_WIN.close();
API_WIN.AUDIO_WIN = null;
}
}
function toggle_audio()
{
if (SHOW_AUDIO) {
//document.AUDIO.src = AUDIO_OFF.src;
API_WIN.SHOW_AUDIO = false;
SHOW_AUDIO = false;
}
else {
//document.AUDIO.src = AUDIO_ON.src;
API_WIN.SHOW_AUDIO = true;
SHOW_AUDIO = true;
}
show_audio();
}
function switch_lang()
{
var tmp_iso_lang = "en";
if (ISO_LANG == "en")
tmp_iso_lang = "es";
//set it in API window
API_WIN.set_lang(tmp_iso_lang);
replay_page();
}
function run_quiz()
{
API_WIN.RUN_QUEST = true;
goto_next_page();
}
function goto_next_question()
{
//make sure questions are there
if (API_WIN.MAX_QUEST_NUM == 0) {
//problem
alert("This Quiz has not been setup correctly. Contact your system administrator.");
}
else {
//if asked all questions, go back to next page in course
if (API_WIN.QUEST_NUM >= API_WIN.MAX_QUEST_NUM) {
if (API_WIN.QUEST_NUM == API_WIN.MAX_QUEST_NUM) {
//questions answered, go to results page
API_WIN.QUEST_NUM += 1;
goto_page("results.htm","next");
}
else {
API_WIN.RUN_QUEST = false;
API_WIN.RUNNING_QUEST = false;
goto_next_page();
}
}
else {
//show next question
var quest_num = 0;
var rand_num = 0;
var quest_id = "";
while ((quest_id == "") && (QUEST_POOL_NUM > 0)) {
//get a random question number
rand_num = Math.random();
quest_num = Math.round(rand_num*(QUEST_POOL_NUM-1));
//check id for that number
if (!item_in_array(QUEST_POOL_LIST[quest_num],API_WIN.QUEST_LIST)) {
//if not in asked auestion list, use it!
quest_id = QUEST_POOL_LIST[quest_num];
}
}
//add question to quest list
API_WIN.QUEST_LIST[API_WIN.QUEST_LIST.length] = quest_id;
//incement question number
API_WIN.QUEST_NUM += 1;
//go to next question
goto_page(quest_id + ".htm","next");
}
}
}
//quiz stuff - test version, provides feedback and moves to next page
function check_answer_test(answer_obj)
{
var ans_list = API_WIN.ANSWER_LIST;
var quest_id = PAGE_NUM;
if (API_WIN.QUEST_NUM > 0)
quest_id = QUEST_ID;
if (!item_in_array(quest_id,ans_list))
{
API_WIN.ANSWER_LIST[API_WIN.ANSWER_LIST.length] = quest_id;
var correct_ans_value = correct_ans(answer_obj,quest_id);
var correct_ans_obj = eval("document.form1." + correct_ans_value);
if ((correct_ans_value != "") && (answer_obj.name == correct_ans_value)) {
//increment correct_answer counter
API_WIN.CORRECT_ANSWERS += 1;
do_feedback(correct_ans_obj,true,false);
}
else
do_feedback(correct_ans_obj,false,false);
}
else
alert ("You've already answered this question!");
//navigate to next question
enable_next(true);
goto_next_page();
}
//quiz stuff - quiz version, provides feedback, if correct moves to next page
function check_answer_quiz(answer_obj)
{
var correct_ans_value = correct_ans(answer_obj,QUEST_ID);
var correct_ans_obj = eval("document.form1." + correct_ans_value);
if ((correct_ans_value != "") && (answer_obj.name == correct_ans_value)) {
do_feedback(correct_ans_obj,true,true);
enable_next(true);
goto_next_page();
}
else {
do_feedback(correct_ans_obj,false,true);
answer_obj.checked = false;
}
}
function do_feedback(correct_ans_obj,correct,use_default)
{
if (SHOW_FEEDBACK) {
if (correct) {
alert(CORRECT_FEEDBACK);
}
else {
var incorrect_feedback = INCORRECT_FEEDBACK;
if (!use_default)
incorrect_feedback = "Incorrect. The correct answer is: '" + correct_ans_obj.value + "'";
alert(incorrect_feedback);
}
}
}
function correct_ans(answer_obj,quest_id)
{
var correct_ans = "";
var correct_ans_num = Math.floor(((1 / (EXT_VALUE / 1000000)) / 3) / quest_id);
switch (correct_ans_num)
{
case 1:
correct_ans = "A";
break;
case 2:
correct_ans = "B";
break;
case 3:
correct_ans = "C";
break;
case 4:
correct_ans = "D";
break;
case 5:
correct_ans = "E";
break;
}
return correct_ans;
}
function write_media()
{
if (ENABLE_AUDIO) {
document.write(MEDIA_HTML);
}
}
function flash_command(command_str)
{
eval(command_str);
}